package com.aptech.springaop83.proxy;

/**
 * 模拟方法的性能
 * 
 * 封装“调用开始时间”和“调用结束时间”
 * 
 * 二者相减，得到调用方法花费的总时间
 * 
 * @author Ryan
 *
 */
public class MethodPerformace {
	
	/**
	 * 开始时间
	 */
	private long begin;
	
	/**
	 * 结束时间
	 */
	private long end;
	
	/**
	 * 方法名称
	 */
	private String serviceMethod;
    
	/**
	 * 构造
	 */
	public MethodPerformace(String serviceMethod){
    	reset(serviceMethod);
    }
    
	/**
	 * 打印性能
	 */
	public void printPerformace(){
        end = System.currentTimeMillis();
        long elapse = end - begin;
        System.out.println(serviceMethod+"花费"+elapse+"毫秒。");
    }
    
	/**
	 * 重设
	 * @param serviceMethod
	 */
	public void reset(String serviceMethod){
    	this.serviceMethod = serviceMethod;
    	this.begin = System.currentTimeMillis();
    }
}
